var $ = getApp(), methods = require("../methods.js");
Page(Object.assign({}, methods, {
	data: {
		datalist: [],
		pagenum: 1
	},
	_onLoad:function(){
		var that = this
		$.get($.pre_url + '/am.php?s=/index/setpwd',{},function(res){
			that.setData(res)
		})
	},
	confirm:function(e){
		var that = this;
		var formdata = e.detail.value
		var oldpwd = formdata.oldpwd
		var pwd = formdata.pwd
		var repwd = formdata.repwd
		if(!oldpwd){
			$.error('请输入原密码');return;
		}
		if(!pwd){
			$.error('请输入新密码');return;
		}
		if(!repwd){
			$.error('请再次输入新密码');return;
		}
		if(pwd != repwd){
			$.error('两次新密码输入不一致');return;
		}
		$.post($.pre_url + '/am.php?s=/index/setpwd',{oldpwd:oldpwd,pwd:pwd,repwd:repwd},function(res){
			if(res.status == 1){
				$.success(res.msg);
				setTimeout(function(){
					$.goback();
				},1000);
			}else{
				$.error(res.msg);
			}
		});
	}
}))